package com.itheima.day07.List;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        //1.创建集合
        List<String> manStar = new ArrayList<>();

        //2.添加模拟数据
        manStar.add("宝强");
        manStar.add("乃亮");
        manStar.add("粤明");
        manStar.add("澄清");
        manStar.add("潇肃");
        manStar.add("雨哥哥");
        //遍历方法1for循环遍历
        for (int i = 0; i < manStar.size(); i++) {
            System.out.println(manStar.get(i));
        }
        System.out.println("-------------");
        //遍历方法2，增强for循环遍历
        for (String name : manStar) {
            System.out.println(name);
        }
        System.out.println("-------------");
        //遍历方法3，迭代器遍历
        Iterator<String> it = manStar.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());
        }
        System.out.println("-------------");
        //遍历方法4，迭代器遍历
        manStar.forEach(System.out::println);
    }
}
